#!/bin/sh

# detection autobak dir
if [ !  -d autobak ];then
	mkdir autobak
else
	echo 'autobak dir exist'
fi

sleep 2
echo "[INFO] kill main.py"
fuser -k nohup.out
echo "[INFO] auto backup nohup.out"

mv nohup.out autobak/nohup.out.autobak.$(date +%Y%m%d%H%M%S)
> nohup.out
echo "[INFO] restart main.py"

nohup python3 -u /usr/local/bin/uvicorn main:app --reload --host 0.0.0.0 --port 8000 >> nohup.out &
